/* eslint-disable */
export default {
  data() {
    return {
      // 资产数据
      assetData:[
        {
          contractNo: '0001201911025861',
          assetName: '办公桌',
          assetType: '办公用品',
          assetNorm: '型号:XXX',
          supplier: 'XXXX供应商',
          purchaseUnit: '购买单位',
          inboundDate: '2019-10-30',
          assetNum: '3',
          includesTax: true,
          fixedAssets: false,
          assetUseYear: '',
          assetStatus: '已审核',
          taxIncludedPrice: '600',
          excludingTaxPrice: '',
        },
        {
          contractNo: '0001201911025031',
          assetName: '办公椅子',
          assetType: '办公用品',
          assetNorm: '型号:XXX',
          supplier: 'XXXX供应商',
          purchaseUnit: '购买单位',
          inboundDate: '2019-10-30',
          assetNum: '1',
          includesTax: true,
          fixedAssets: false,
          assetUseYear: '',
          assetStatus: '已审核',
          taxIncludedPrice: '200',
          excludingTaxPrice: '',
        },
        {
          contractNo: '0001201911025031',
          assetName: '文件夹',
          assetType: '办公用品',
          assetNorm: '型号:XXX',
          supplier: 'XXXX供应商',
          purchaseUnit: '购买单位',
          inboundDate: '2019-10-30',
          assetNum: '1',
          includesTax: true,
          fixedAssets: false,
          assetUseYear: '',
          assetStatus: '待审核',
          taxIncludedPrice: '200',
          excludingTaxPrice: '',
        },
        {
          contractNo: '0001201911024234',
          assetName: '办公椅',
          assetType: '办公用品',
          assetNorm: 'cpu:i7 9700k 内存：16g 硬盘：256g固态 显卡：gtx1050ti 系统：win10',
          supplier: 'XXXX供应商',
          purchaseUnit: '购买单位',
          inboundDate: '2019-10-30',
          assetNum: '5',
          includesTax: true,
          fixedAssets: false,
          assetUseYear: '',
          assetStatus: '已审核',
          children: [],
          taxIncludedPrice: '700',
          excludingTaxPrice: '',
        },
        {
          contractNo: '0001201911024234',
          assetName: '笔记本',
          assetType: '办公用品',
          assetNorm: '型号:XXX',
          supplier: 'XXXX供应商',
          purchaseUnit: '购买单位',
          inboundDate: '2019-10-30',
          assetNum: '1',
          includesTax: true,
          fixedAssets: false,
          assetUseYear: '',
          assetStatus: '已审核',
          taxIncludedPrice: '200',
          excludingTaxPrice: '',
        },
        {
          contractNo: '0001201911027165',
          assetName: '签字笔',
          assetType: '办公用品',
          assetNorm: '型号:XXX',
          supplier: 'XXXX供应商',
          purchaseUnit: '购买单位',
          inboundDate: '2019-10-30',
          assetNum: '2',
          includesTax: true,
          fixedAssets: false,
          assetUseYear: '',
          assetStatus: '已审核',
          children: [],
          taxIncludedPrice: '100',
          excludingTaxPrice: '',
        },
      ],

      // 资产图片上传
      dialogImageUrl: '',
      dialogVisible: false,
      disabled: false,

      // 新增资产弹窗
      dialogAssetAdd:{
        title: '资产审核',
        status: false,
      },

      // 新增资产表单数据
      assetAddFrom:{
        assetName: '',
        assetType: '',
        inboundDate: '',
        assetNorm: '',
        assetNum: '',
        includesTax: true,
        supplier: '',
        contractNo: '',
        purchaseUnit: '',
        fixedAssets: false,
        assetUseYear: '',
        taxIncludedPrice: '', // 含税价
        excludingTaxPrice: '', // 不含税价
      },

      // 新增资产表单验证
      assetAddRules: {
        assetName: [
          { required: true, message: '请输入资产名称', trigger: 'blur' },
        ],
        assetType: [
          { required: true, message: '请选择资产类型', trigger: 'change' },
        ],
      },

      // 资产领取表单
      uerFrom:{
        userEmployer: '',
        usertel: '',
        userName: '',
        administrator: '',
        deadline: '',
        position: '',
        userCompany: '',
        userMoney: '',
      },

      // 资产领用
      dialogAssetUse:{
        title: '资产领用',
        status: false,
      },

      //  资产领用表单验证
      userRules: {
        userEmployer: [
          { required: true, message: '请输入资产名称', trigger: 'blur' },
        ],
        usertel: [
          { required: true, message: '请输入资产名称', trigger: 'blur' },
        ],
        userName: [
          { required: true, message: '请输入资产名称', trigger: 'blur' },
        ],
        administrator: [
          { required: true, message: '请输入资产名称', trigger: 'blur' },
        ],
        deadline: [
          { required: true, message: '请选择资产类型', trigger: 'change' },
        ],
        position: [
          { required: true, message: '请输入资产名称', trigger: 'blur' },
        ],
        userMoney: [
          { required: true, message: '请输入领用金额', trigger: 'blur' },
        ],
        userCompany: [
          { required: true, message: '请输入领用公司', trigger: 'blur' },
        ],
      },

      // 筛选条件表单
      conditionFrom:{
        filterType: '1',
        assetName: '',
        assetType: '',
      },

      // 表单数据选择
      multipleSelection: [],
      price: 0,

    }
  },
  mounted() {

  },
  methods: {
    // 资产弹窗
    dialogAsset(row){
      this.assetAddFrom = row
      this.dialogAssetAdd.status = true
    },

    // 资产照片上传
    uploadFuc(){
      this.$message({
        type: 'success',
        message: '上传失败!'
      })
    },
    successFuc(){
      this.$message({
        type: 'success',
        message: '上传成功!'
      })
    },
    handleRemove(file) {
      console.log(file);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },

    // 资产领用弹窗
    dialogUse(){
      this.uerFrom = {
        userEmployer: '',
        usertel: '',
        userName: '',
        administrator: '',
        deadline: '',
        position: '',
        userCompany: '',  
        userMoney: this.price,
      },
      this.dialogAssetUse.status = true
    },

    // 资产领用
    assetUse(formName){
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$message({
            type: 'success',
            message: '领用成功!'
          })
          this.dialogAssetUse.status = false
        } else {
          this.$message({
            type: 'warning',
            message: '请填写相关信息!'
          })
          return false;
        }
      });
    },

    // 查询
    searchData(){
      this.$message({
        type: 'success',
        message: '查询成功!'
      })
    },

    // 表单数据选择
    handleSelectionChange(val) {
      this.price = 0
      val.forEach(element => {
        this.price += parseInt(element.taxIncludedPrice)
      });
      this.multipleSelection = val;
    }
  }
}